package com.iplatform.commons.utils;


import com.iplatform.commons.customGson.GsonOutIsNotNull;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * gjson 对象单例处理
 * @author houkunliang
 * @createDate 2018年10月23日
 */
public class GosonUtil
{
  private static volatile Gson gson;

  public static Gson getGson()
  {
    if (null == gson) {
      synchronized (GosonUtil.class)
      {
        if (null == gson) {
        	GsonBuilder gsonBuilder = new GsonBuilder();
        	gsonBuilder.registerTypeAdapter(String.class, new GsonOutIsNotNull());
        	gson = gsonBuilder.serializeNulls().create();
//        	gson = new GsonBuilder().serializeNulls().create();
        }
      }
    }
    return gson;
  }

}
